﻿@{
    Layout = "~/Views/Shared/_PopupLayout.cshtml";
}

@model LineOfBusiness.Poco.IV_tblItemLists

@Html.LOBHtmlHelper().Busy("pupopBusy")
@{Html.LOBHtmlHelper().tdLable("120");}

<style>
 fieldset {
    margin: 8px;
    border: 1px solid silver;
    padding: 8px;    
    border-radius: 4px;
} 
legend{
    padding: 2px;        
}
</style>
 
<div>
    <form id="frm">
        <table style="width:100%;padding-left:15px;padding-right:15px">
            <tr>
                <td>
                    <table style="width:100%;padding-left:15px;padding-right:15px">
                        <tr>
                            <td class="tdLabel">
                                @Html.LOBHtmlHelper().Label("lblItemID", "ItemID")
                            </td>
                            <td>
                                @Html.LOBHtmlHelper().InputFor("ItemID", InputType.Text, 1)
                            </td>
                        </tr>


                        <tr>
                            <td class="tdLabel">
                                @Html.LOBHtmlHelper().Label("lblItemName", "ItemName")
                            </td>
                            <td>
                                @Html.LOBHtmlHelper().InputFor("ItemName", InputType.Text, 1)

                            </td>

                        </tr>

                        <tr>
                            <td class="tdLabel">
                                @Html.LOBHtmlHelper().Label("lblItemType", "ItemType")
                            </td>
                            <td>
                                @Html.LOBHtmlHelper().ComboBoxFor("ItemType", "L0001", 0, new { style = "width:100%" })
                            </td>

                        </tr>


                        <tr>
                            <td class="tdLabel">
                                @Html.LOBHtmlHelper().Label("lblItemGroupID", "ItemGroupID")
                            </td>
                            <td>
                                @Html.LOBHtmlHelper().ComboBoxFor("ItemGroupID", "tblItemGroupList", 0, new { style = "width:100%" })
                            </td>

                        </tr>


                        <tr>
                            <td class="tdLabel">
                                @Html.LOBHtmlHelper().Label("lblNetWeight", "NetWeight")
                            </td>
                            <td>
                                @Html.LOBHtmlHelper().InputFor("NetWeight", InputType.Text, 1)

                            </td>

                        </tr>



                        <tr>
                            <td class="tdLabel">
                                @Html.LOBHtmlHelper().Label("lblColor", "Color")
                            </td>
                            <td>
                                @Html.LOBHtmlHelper().InputFor("Color", InputType.Text, 1)

                            </td>

                        </tr>



                        <tr>
                            <td class="tdLabel">
                                @Html.LOBHtmlHelper().Label("lblSize", "Size")
                            </td>
                            <td>
                                @Html.LOBHtmlHelper().InputFor("Size", InputType.Text, 1)

                            </td>

                        </tr>

                        <tr>
                            <td class="tdLabel">
                                @Html.LOBHtmlHelper().Label("lblGoldAgeID", "GoldAgeID")
                            </td>
                            <td>
                                @Html.LOBHtmlHelper().ComboBoxFor("GoldAgeID", "tblGoldAge", 0, new { style = "width:100%" })
                            </td>

                        </tr>

                        <tr>
                            <td>
                                @Html.LOBHtmlHelper().Label("lblNotes", "Notes")
                            </td>


                            <td>
                                @Html.LOBHtmlHelper().InputFor("Notes", InputType.Text, "100")
                            </td>

                        </tr>

                    </table>
                </td>
                <td style="vertical-align: top; text-align: center; width: 200px;">
                    <div style="margin-left:60px;border-color: #808080; border-style: solid; border-width: 1px; width: 100px; height: 100px">
                        <img id="image" style=" width: 100px; height: 100px" />
                    </div>

                    <div class="buttons">
                        <input type='file' id="asd" />

                        <button class="positive" onclick="OpenCamera()" type="button">
                            <img src="@Html.BaseUrl()Content/default/images/webcamlogo.png" alt="" />
                            @Html.LOBHtmlHelper().C("Camera")
                        </button>
                    </div>

                    <div>
                        @Html.LOBHtmlHelper().Label("lblBarcodeID", "BarcodeID")
                    </div>
                    <div id="barcode" style="width:100px; height:70px;border-style:solid;border-width:1px;border-color:#808080"></div>
                    
            </tr>
        </table>

        <div id="_blank" style="height:25px"></div>
</form>
</div>

<div class="Line">
</div>

<div  style="text-align:right">
    <div class="buttons">
        @if(ViewBag.Edit!=-1)
        {
            <button id="btnSave" class="positive" onclick= "SavePopup()">
                <img src="@Html.BaseUrl()Content/images/toolbar/save.png" alt="" /> 
                @Html.LOBHtmlHelper().C("Save") 
            </button> 
        }
        <button class="positive" onclick= "Close()">
            <img src="@Html.BaseUrl()Content/images/toolbar/close.png" alt="" /> 
            @Html.LOBHtmlHelper().C("Close")
        </button> 
    </div>
</div>

<script language="JavaScript" src="~/Scripts/jquery-barcode.min.js"></script>

<script type="text/javascript">

    var codeBasePopup = new CodeBasePopup();

    $(document).ready(function () {

        codeBasePopup.init('@ViewBag.Edit', "ItemID", "@Url.Action("Save", "ItemLists")", '@Model.ItemID', "", 80);

        setTimeout(function () { $("#ItemID").focus(); }, 500);

        $('#ItemID').unbind().bind('focusout', function () {
            $("#barcode").barcode(
             $('#ItemID').val(), // Value barcode (dependent on the type of barcode)
             "code128" // type (string)
             );
        });

    });

    function readImage(input) {
        if (input.files && input.files[0]) {
            var FR = new FileReader();
            FR.onload = function (e) {
                $('#image').attr("src", e.target.result);
                
            };
            FR.readAsDataURL(input.files[0]);
        }
    }

    $("#asd").change(function () {
        readImage(this);
    });

    function SavePopup() {
        codeBasePopup.SavePopup();
    }

    function Close() {
        codeBasePopup.Close();
    }

    function OpenCamera()
    {
        ShowWindowCallback("@Url.Action("CaptureWebcam", "Shared")", 320, 320, "Camera", function (e)
        {
            $('#image').attr("src", "data:image/png;base64," + e);
        });
    }
</script>